﻿
using System.Web;

namespace Southern.Common.ClientResource
{
    /// <summary>
    /// A class resolves the relative url on local web server
    /// </summary>
    public class ResoureUrlResolver : IUrlResolver
    {
        public ResoureUrlResolver()
        {
        }
        #region IUrlResolver Members

        public string ToAbsoluteUrl(string relativeUrl)
        {
            if (string.IsNullOrEmpty(relativeUrl))
                throw new System.NullReferenceException("@relativeUrl cannot be null or empty");
            relativeUrl = relativeUrl.Trim();
            if (relativeUrl.StartsWith("~/"))
            {
                return VirtualPathUtility.ToAbsolute(relativeUrl);
                //throw new ArgumentException("The url is not a relative url. A relative url must start with \"~/\" characters.");
            }
            else
            {
                return relativeUrl;
            }
        }

        #endregion
    }
}
